package com.yc.navy.goods.config.filter;

import java.io.IOException;

import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;

/**
 * 消息总线请求处理过滤器
 * @author navy
 * Company 源辰信息
 * @date 2022年7月24日
 * Email haijunzhou@hnit.edu.cn
 */
public class BusRefreshFilter implements Filter{
	@Override
	public void init(FilterConfig filterConfig) throws ServletException {
		
	}

	@Override
	public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
			throws IOException, ServletException {
		HttpServletRequest req = (HttpServletRequest) request;
		String url = req.getRequestURI();
		System.out.println("url*** = " + url);
		if (!url.endsWith("/bus-refresh")) {
			chain.doFilter(request, response);
			return;
		}
		
		CustomerRequestWrapper requestWrapper = new CustomerRequestWrapper(req);
		chain.doFilter(requestWrapper, response);
	}

	@Override
	public void destroy() {
		
	}
}
